﻿using System;
using System.Collections.Generic;

    class Program
    {
        static int ReverseDigits(int number)
        {
            int reversed = 0;
            while (number > 0)
            {
                reversed = (reversed * 10) + number % 10;
                number = number / 10;
            }
            return reversed;
            
        }

        static int AverageOfSequence(int[] arr)
        {
            int sum = 0;
            int average=0;
            int length = arr.Length;
            for (int i = 0; i < arr.Length; i++)
            {
                sum = sum + arr[i];
                average = sum / length;
            }
            return average;
        }
        static double LinearEqution(double a, double b)
        {
            double res = -b / a;
            return res;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("1. Reverse the digits of a non negative number.    ");
            Console.WriteLine("2. Calculate the avarage of a sequence of integers.");
            Console.WriteLine("3. Solve a linear equation a * x + b = 0 .         ");          
            Console.Write("Choose a task number from 1 to 3 : ");
            int task = int.Parse(Console.ReadLine());
            if (task == 1)
            {
                Console.Write("Enter positive number: ");
                int num = int.Parse(Console.ReadLine());           
              
                int reversed=ReverseDigits(num);
                Console.WriteLine("The reversed number is: {0}", reversed);

            }
            if (task == 2)
            {
                Console.Write("Enter a positive number: ");
                int n = int.Parse(Console.ReadLine());
                int[] arr=new int[n];
                Console.WriteLine("Enter the elements of the seqence:");
                for (int i = 0; i < n; i++)
                {
                   arr[i]=int.Parse(Console.ReadLine());
                }
                int average=AverageOfSequence(arr);
                Console.WriteLine("The average of the array's elements is {0}", average);
            }
            if (task == 3)
            {
                Console.Write("Enter a= ");
                double a = double.Parse(Console.ReadLine());
                Console.Write("Enter b= ");
                double b = double.Parse(Console.ReadLine());
                double res = LinearEqution(a, b);
                Console.WriteLine(res);
            }


        }
    }
